//籍贯饼状图
var place = echarts.init(document.getElementById('place'));
async function renderPlace() {
    const res = await axios.get('student/list')
    //声明空数组
    const data = []
    //遍历数据
    const students = res.data.data;
    students.forEach(ietm => {
        const p = data.find(list => list.name === ietm.province)
        if (p === undefined) {
            const o = {
                name: ietm.province,
                value: 1,
            }
            data.push(o)
        } else {
            p.value++
        }
    })
    const pieChart = {
        title: {
            text: '籍贯 Hometown',
            textStyle: {
                color: '#6d767e'
            }
        },
        tooltip: {
            formatter: '<h1 style="color: pink;">{a}<br/>{b}省{c}人 占比{d}</h1>'
        },
        series: [
            {
                name: '各地人员分布',
                type: 'pie',
                center: ['50%', '50%'],
                roseType: 'area',
                itemStyle: {
                    borderRadius: 8
                },
                data,
            }
        ]
    };
    place.setOption(pieChart);
}


renderPlace()